package com.wandian.cqcsk.adapter.home;


import android.widget.ImageView;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.iBookStar.views.YmConfig;
import com.wandian.cqcsk.R;

import static com.mylib.libcore.config.AppConfig.YUEMENG_APP_ID;

/**
 * 主频底部按钮-适配器
 */
public class MainBtnRecycleAdapter extends BaseQuickAdapter<String, BaseViewHolder> {

    private String selectText;//默认选中文字
    public MainBtnRecycleAdapter(int layoutResId,String defaultString) {
        super(layoutResId);
        this.selectText = defaultString+"";
    }

    @Override
    protected void convert(BaseViewHolder helper, String item) {
        ImageView iv_home_btn_icon = helper.getView(R.id.iv_home_btn_icon);
        TextView tv_home_btn_title = helper.getView(R.id.tv_home_btn_title);
        tv_home_btn_title.setText(item);
        tv_home_btn_title.setTextColor(mContext.getResources().getColor(R.color.black));
        if(selectText.equals(item)){
            tv_home_btn_title.setTextColor(mContext.getResources().getColor(R.color.white));
            notifySelectImg(iv_home_btn_icon,item);
        }else {
            setTitleImg(iv_home_btn_icon,item);
        }

    }

    public void  notifySelectItemState(String selectString){
        this.selectText = selectString;
        notifyDataSetChanged();
    }

    //刷新选择图片
    private void notifySelectImg(ImageView ivBtn,String selectString){
        switch (selectString){
            case "天气":
                ivBtn.setImageResource(R.drawable.img_home_btn_weather_select);
                break;
            case "资讯":
                ivBtn.setImageResource(R.drawable.img_home_btn_news_select);
                break;
            case "游戏":
                ivBtn.setImageResource(R.drawable.img_home_btn_games_select);
                break;
            case "玩赚":
                ivBtn.setImageResource(R.drawable.img_home_btn_wz_select);
                break;
            case "音乐":
                ivBtn.setImageResource(R.drawable.img_home_btn_music_select);
                break;
            case "我的":
                ivBtn.setImageResource(R.drawable.img_home_btn_mine_select);
                break;
            case "小说":
                ivBtn.setImageResource(R.drawable.img_home_btn_book_select);
                break;
            case "视频":
                ivBtn.setImageResource(R.drawable.img_home_btn_video_select);
                break;
            case "微文":
                ivBtn.setImageResource(R.drawable.img_home_btn_wxtop_select);
                break;
            case "生活":
                ivBtn.setImageResource(R.drawable.img_home_btn_life_select);
                break;
            case "智库":
                ivBtn.setImageResource(R.drawable.img_home_btn_knowledge_select);
                break;
        }
    }

    //设置title图片
    private void setTitleImg(ImageView ivBtn,String title){
        switch (title){
            case "天气":
                ivBtn.setImageResource(R.drawable.img_home_btn_weather_unselect);
                break;
            case "资讯":
                ivBtn.setImageResource(R.drawable.img_home_btn_news_unselect);
                break;
            case "游戏":
                ivBtn.setImageResource(R.drawable.img_home_btn_games_unselect);
                break;
            case "玩赚":
                ivBtn.setImageResource(R.drawable.img_home_btn_wz_unselect);
                break;
            case "音乐":
                ivBtn.setImageResource(R.drawable.img_home_btn_music_unselect);
                break;
            case "我的":
                ivBtn.setImageResource(R.drawable.img_home_btn_mine_unselect);
                break;
            case "小说":
                ivBtn.setImageResource(R.drawable.img_home_btn_book_unselect);
                break;
            case "视频":
                ivBtn.setImageResource(R.drawable.img_home_btn_video_unselect);
                break;
            case "微文":
                ivBtn.setImageResource(R.drawable.img_home_btn_wxtop_unselect);
                break;
            case "生活":
                ivBtn.setImageResource(R.drawable.img_home_btn_life_unselect);
                break;
            case "智库":
                ivBtn.setImageResource(R.drawable.img_home_btn_knowledge_unselect);
                break;
        }
    }

}
